package com.neuedu.common.enums;


import com.neuedu.common.enums.base.BaseEnum;

public enum YesNoEnum implements BaseEnum {

    NO(0, "否"),

    YES(1, "是"),
    ;

    private final Integer code;

    private final String value;

    YesNoEnum(Integer code, String value) {
        this.code = code;
        this.value = value;
    }

    @Override
    public Integer getCode() {
        return code;
    }

    @Override
    public String getValue() {
        return value;
    }

    public String getCodeOfString() {
        return String.valueOf(code);
    }

    public static YesNoEnum getByCode(Integer code) {
        for (YesNoEnum item : YesNoEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }

        return null;
    }

    public static YesNoEnum getByCode(String codeStr) {
        int code = Integer.parseInt(codeStr);
        for (YesNoEnum item : YesNoEnum.values()) {
            if (item.getCode().equals(code)) {
                return item;
            }
        }

        return null;
    }

    public static YesNoEnum getByValue(String value) {
        for (YesNoEnum item : YesNoEnum.values()) {
            if (item.getValue().equals(value)) {
                return item;
            }
        }

        return null;
    }

}
